package cn.itheima.student.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.itheima.student.service.StudentService;
import cn.itheima.student.service.impl.StudentServiceImpl;


public class StudentDeleteServlet1 extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html");
		request.setCharacterEncoding("utf-8");
		
		String sid = request.getParameter("sid");
		
		StudentService service = new StudentServiceImpl();
		service.deleteStudentBySid(sid);
		response.getWriter().write("<font color='green' size='25'>删除成功 2秒之后发生跳转到主页....</font>");
        response.setHeader("Refresh", "2;URL="+request.getContextPath()+"/StudentFindAllServlet1");
				
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
